﻿@model EventSys.BussinesEntities.Ambiente

@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script type="text/javascript">

    function OnSuccessAdd(data) {
        console.log("agregando ventana");
        $("#dialogAddUbicacion").dialog({
            modal: true,
            width: 850,
            //autoOpen: false,
            show: {
                effect: "shake",
                duration: 1000
            },    
            buttons: {
                'Cerrar': function () {
                    $(this).dialog('close');
                },
                //------------------------------
                'Guardar': function () {
                    $.validator.unobtrusive.parse('#frmGuardar');
                    $("#frmGuardar").submit();                    
                    $(this).dialog('close');
                    location.reload();
                }
            },
            close: function () {
                $(this).parent().remove();
                $(this).remove();
            }
        }); 

    }  



</script>

<h2>CREAR NUEVO AMBIENTE</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Ambiente</legend>

        @*<div class="editor-label">
            @Html.LabelFor(model => model.idAmbiente)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.idAmbiente)
            @Html.ValidationMessageFor(model => model.idAmbiente)
        </div>*@

        <div class="editor-label">
            @Html.LabelFor(model => model.Descripcion)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Descripcion)
            @Html.ValidationMessageFor(model => model.Descripcion)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Ubicacion)
        </div>
        <div class="editor-field">
           @*@Html.EditorFor(model => model.idUbicacion)*@
           @Html.DropDownList("idUbicacion") 
          @* @Ajax.ActionLink("Ingrese Ubicación ","create","Ubicacion", new { /*id = item.idEvents*/ },new AjaxOptions { UpdateTargetId="vistaUbicaciones" })*@
            
           @Ajax.ActionLink("Ingrese Ubicacion","Create",new AjaxOptions()
           {
               Url = Url.Action("Create", "Ubicacion"),
               UpdateTargetId = "showAdd",
               OnSuccess = "OnSuccessAdd"
           })
           @Html.ValidationMessageFor(model => model.idUbicacion)
        </div>

        <p>
            <input type="submit" value="CREAR" class="k-button"/>
        </p>
        
    </fieldset>    
    
    <div id="showAdd" >        
        @*mostrar la vista parcial, es decir el lugar*@
    </div>      
    
}

@*<div>
    @Html.ActionLink("Regresar", "Index")
</div>*@

@*@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}*@

